package cn.cdu.medical.service.impl;

import cn.cdu.medical.entity.MedicalRecordRevision;
import cn.cdu.medical.mapper.MedicalRecordRevisionMapper;
import cn.cdu.medical.service.MedicalRecordRevisionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MedicalRecordRevisionServiceImpl extends ServiceImpl<MedicalRecordRevisionMapper, MedicalRecordRevision> implements MedicalRecordRevisionService {

    @Override
    public boolean saveRevision(MedicalRecordRevision revision) {
        // 设置修改时间
        revision.setCreateTime(new Date());
        return save(revision);
    }

    @Override
    public List<MedicalRecordRevision> getRevisionHistory(String recordId) {
        return lambdaQuery()
                .eq(MedicalRecordRevision::getRecordId, recordId)
                .orderByDesc(MedicalRecordRevision::getCreateTime)
                .list();
    }
} 